increment values in printf [migrated]

Posted by ravi_arya on Programmers See other posts from Programmers or by ravi_arya
Published on 2012-11-21T10:49:48Z Indexed on 2012/11/21 11:22 UTC
Read the original article Hit count: 148

Filed under:
#include <stdio.h>

int main()
{ 
    int i=1;

    printf("%d %d %d\n",i,++i,i++);

    i=1;
    printf("%d %d %d\n",++i,i,i++);

    i=1;
    printf("%d %d %d\n",i++,++i,i);

    i=1;
    printf("%d %d %d\n",i++,i,++i);

    i=1;
    printf("%d %d %d\n",++i,i++,i);

    i=1;
    printf("%d \n",(++i)*(++i)*(++i));

    i=1;
    printf("%d %d %d\n",++i, ++i, ++i);

    return 0;
}

Output (GCC)

3 3 1 
3 3 1 
2 3 3 
2 3 3 
3 1 3 
36 
4 4 4 

Output(Visual Studio)

3 3 1
3 3 1
2 3 3
2 3 3
3 1 3
64
4 4 4

Can any one explain this?

© Programmers or respective owner

Related posts about c